clc;
clear;
for ii = 1:1
    disp(['第', num2str(ii), '次循环']);
    % 加载数据
    features_filename1 = sprintf('./classification_results_time_5_1.mat');
    features_filename2 = sprintf('./classification_results_frequency_5_1.mat');
    % 加载文件1和文件2
    data1 = load(features_filename1);
    data2 = load(features_filename2);
    
    % 提取数据矩阵和标签
    matrix1 = data1.combined_features; % 假设数据矩阵在文件1中叫做 matrix1
    matrix2 = data2.combined_features; % 假设数据矩阵在文件2中叫做 matrix2
    labels1 = matrix1(:, end); % 文件1的标签
    labels2 = matrix2(:, end); % 文件2的标签
    
    % 检查标签是否相同
    if ~isequal(labels1, labels2)
        error('标签不匹配');
    end
    
    % 提取数据（不包括最后的标签列）
    data1_without_label = matrix1(:, 1:end-1);
    data2_without_label = matrix2(:, 1:end-1);
    
    % 拼接数据矩阵
    combined_features = [data1_without_label, data2_without_label, labels1];
    features_filename3 = sprintf('classification_results_basic_5_%d.mat', ii);
    % 保存拼接后的数据到新的文件
    save(features_filename3, 'combined_features');
end
